package com.hjs.pacloudservice.service.Impl;

import com.hjs.pacloudservice.remote.FileUploadRemote;
import com.hjs.pacloudservice.service.RedisService;
import com.hjs.pacloudservice.util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @auther hanjinsong
 * @create 2019-08-06 15:40
 */
@Service
public class RedisServiceImpl implements RedisService {

    @Autowired
    private FileUploadRemote fileUploadRemote;

    @Autowired
    private RedisUtils redisUtils;

    @Override
    public int init() {
        List<String> allName = fileUploadRemote.selectAllName();
        for(String name : allName){
            redisUtils.set(name,"http://localhost:8080/files/"+name);
        }
        return 0;
    }

    @Override
    public Map selectAll() {
        HashMap map = redisUtils.getRedis();
        return map;
    }

    @Override
    public List<String> selectAllValues() {
        List<String> list = redisUtils.getAllValues();
        return list;
    }
}
